package com.benmei.weike.entity;

import com.benmei.weike.common.Constants;

import java.math.BigDecimal;
import java.util.Date;

/**
 * Created by Peter on 2018/10/8.
 */
public class McCourse {
   private Integer id;//	int
   private String title;//	varchar
   private String cover_small_url;//	varchar
   private String cover_larger_url;//	varchar
   private Integer max_buy_user_number;//	int
   private Integer actual_buy_user_number;//	int
   private Date appointment_end_time;//	datetime
   private Date appointment_start_time;//	datetime
   private Date sale_start_time;//	datetime
   private Date sale_end_time;//	datetime
   private Date course_start_time;//	datetime
   private Date course_end_time;//	datetime
   private Integer cou_size;//	int
   private Integer putaway;//	int
   private Integer hot;//	int
   private BigDecimal price;//	float
   private BigDecimal group_price;//	float
   private Integer group_max_size;//	int
   private String detail_image_url;//	varchar
   private String teacher_intro_image_url;//	varchar
   private Date create_date;//	timestamp
   private Date update_date;//	timestamp

    private Integer sale_state;//销售状态：0 未开始销售；1 预售；2 开始销售（限售）；3 售完
    public Integer getSale_state() {
        Long currentTime = System.currentTimeMillis();
        if (currentTime < this.appointment_start_time.getTime()) {
            sale_state = Constants.McCourse.SaleState.unStart;
        } else if (currentTime >= this.appointment_start_time.getTime() && currentTime <= this.appointment_end_time.getTime()) {
            sale_state = Constants.McCourse.SaleState.preSale;
        } else if (currentTime >= this.sale_start_time.getTime() && currentTime <= this.sale_end_time.getTime() && this.actual_buy_user_number >= this.max_buy_user_number) {
            sale_state = Constants.McCourse.SaleState.saleOver;
        } else if (currentTime > this.sale_end_time.getTime()) {
            sale_state = Constants.McCourse.SaleState.saleOver;
        } else {
            sale_state = Constants.McCourse.SaleState.sale;
        }
        return sale_state;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getCover_small_url() {
        return cover_small_url;
    }

    public void setCover_small_url(String cover_small_url) {
        this.cover_small_url = cover_small_url;
    }

    public String getCover_larger_url() {
        return cover_larger_url;
    }

    public void setCover_larger_url(String cover_larger_url) {
        this.cover_larger_url = cover_larger_url;
    }

    public Integer getMax_buy_user_number() {
        return max_buy_user_number;
    }

    public void setMax_buy_user_number(Integer max_buy_user_number) {
        this.max_buy_user_number = max_buy_user_number;
    }

    public Integer getActual_buy_user_number() {
        return actual_buy_user_number;
    }

    public void setActual_buy_user_number(Integer actual_buy_user_number) {
        this.actual_buy_user_number = actual_buy_user_number;
    }

    public Date getAppointment_end_time() {
        return appointment_end_time;
    }

    public void setAppointment_end_time(Date appointment_end_time) {
        this.appointment_end_time = appointment_end_time;
    }

    public Date getAppointment_start_time() {
        return appointment_start_time;
    }

    public void setAppointment_start_time(Date appointment_start_time) {
        this.appointment_start_time = appointment_start_time;
    }

    public Date getSale_start_time() {
        return sale_start_time;
    }

    public void setSale_start_time(Date sale_start_time) {
        this.sale_start_time = sale_start_time;
    }

    public Date getSale_end_time() {
        return sale_end_time;
    }

    public void setSale_end_time(Date sale_end_time) {
        this.sale_end_time = sale_end_time;
    }

    public Date getCourse_start_time() {
        return course_start_time;
    }

    public void setCourse_start_time(Date course_start_time) {
        this.course_start_time = course_start_time;
    }

    public Date getCourse_end_time() {
        return course_end_time;
    }

    public void setCourse_end_time(Date course_end_time) {
        this.course_end_time = course_end_time;
    }

    public Integer getCou_size() {
        return cou_size;
    }

    public void setCou_size(Integer cou_size) {
        this.cou_size = cou_size;
    }

    public Integer getPutaway() {
        return putaway;
    }

    public void setPutaway(Integer putaway) {
        this.putaway = putaway;
    }

    public Integer getHot() {
        return hot;
    }

    public void setHot(Integer hot) {
        this.hot = hot;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public BigDecimal getGroup_price() {
        return group_price;
    }

    public void setGroup_price(BigDecimal group_price) {
        this.group_price = group_price;
    }

    public Integer getGroup_max_size() {
        return group_max_size;
    }

    public void setGroup_max_size(Integer group_max_size) {
        this.group_max_size = group_max_size;
    }

    public String getDetail_image_url() {
        return detail_image_url;
    }

    public void setDetail_image_url(String detail_image_url) {
        this.detail_image_url = detail_image_url;
    }

    public String getTeacher_intro_image_url() {
        return teacher_intro_image_url;
    }

    public void setTeacher_intro_image_url(String teacher_intro_image_url) {
        this.teacher_intro_image_url = teacher_intro_image_url;
    }

    public Date getCreate_date() {
        return create_date;
    }

    public void setCreate_date(Date create_date) {
        this.create_date = create_date;
    }

    public Date getUpdate_date() {
        return update_date;
    }

    public void setUpdate_date(Date update_date) {
        this.update_date = update_date;
    }
}
